﻿using System;

namespace Borg.Framework
{
    public class ReleaseAction : Action
    {
        public ReleaseAction(SlotInfo slot, QualifyDelegate qualify)
            : base(slot, qualify)
        { }

        public ReleaseAction(SlotInfo slot, string param, object value)
            : base(slot, param, value)
        { }

        public override void Do(object s, EventArgs args)
        {
            for (var i = Slot.PluggedPlugInfos.Count - 1; i >= 0; i--)
            {
                var plug = Slot.PluggedPlugInfos[i];

                if (Qualify == null || Qualify(plug.PlugTypeInfo))
                    plug.ExtensionInfo.Release();
            }
        }
    }
}

